<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <script type="text/javascript" src="jquery-1.10.1.js"></script>
</head>
<body>
<div id="app"></div>
<input type="button" onclick="btnClick()" value="get_button">
<input type="button" onclick="btnClick2()" value="post_button">
<script>
    function btnClick() {
        /*$.get('http://localhost:8080/hello',function (msg) {
            $("#app").html(msg);
        });*/
        $.ajax({
            type: 'GET',
            url: 'http://localhost:8080/hello',
            dataType: 'json',
            data: {
                type: 'get',
            },
            success: function (result) {
                console.log(result)
                $("#app").html(result);
                alert("请求成功")
            },
            error: function () {
                console.log()
                alert('服务器走丢了')
            }
        });
    }

    function btnClick2() {
       /* $.post('http://localhost:8080/hello', function (msg) {
            $("#app").html(msg);
        });*/

        $.ajax({
            type: 'POST',
            url: 'http://localhost:8080/hello',
            dataType: 'json',
            data: {
                type: 'post',
            },
            success: function (result) {
                console.log(result)
                $("#app").html(result);
                alert("请求成功")
            },
            error: function () {
                console.log()
                alert('服务器走丢了')
            }
        });
    }
</script>
</body>
</html>